<?php

class DB {
	
	function __construct() {
		$this->connect();
	}
	
	function __destruct() {
		
		if( is_null($this->result)){
			mysql_free_result($this->result);
		}
		mysql_close($this->conn);
	}
	
	private function connect() {
		$this->setConnectionInfo();
		$this->conn = mysql_connect ( $this->host_name, $this->user, $this->passwd );		
		mysql_select_db($this->db_name);
	}
	
	public function setConnectionInfo($host = 'localhost', $user = 'root', $passwd = 'lplus', $db_name = 'flxx') {
		$this->host_name = $host;
		$this->user = $user;
		$this->passwd = $passwd;
		$this->db_name = $db_name;
	}
	
	public function sqlQuery($sql_command){
		
		$this->result = mysql_query($sql_command);
		return $this->result;
	}
	
	public function fetchArray(){
		return mysql_fetch_array($this->result, MYSQL_ASSOC);
	}
	private $host_name = '';
	
	private $user = '';
	
	private $passwd = '';
	
	private $db_name;
	
	private $conn;
	
	private $result;
	
}

?>